//1.引入二次封装好的axios 名字最好不要叫axios
import request from '@/utils/request';
import type {
  TrademarkInfoModel,
  TrademarkListDataModel,
} from './model/trademarkModel';

//写接口函数

//2. 给结果添加枚举
enum Api {
  //2.1 获取品牌列表数据
  getTrademarkListApi = '/admin/product/baseTrademark',
  //2.2 新增品牌
  saveTrademarkInfoApi = '/admin/product/baseTrademark/save',
  //2.3 删除品牌
  removeTrademarkInfoApi = '/admin/product/baseTrademark/remove',
  //2.4 更新品牌
  updateTrademarkInfoApi = '/admin/product/baseTrademark/update',
}

//3. 定义一个获取品牌列表的接口函数
export const reqGetTrademarkListData = (page: number, limit: number) => {
  return request.get<any, TrademarkListDataModel>(
    `/admin/product/baseTrademark/${page}/${limit}`
  );
};

//4. 新增品牌 /admin/product/baseTrademark/save
export const reqSaveTrademarkInfo = (trademarkInfo: TrademarkInfoModel) => {
  return request.post(Api.saveTrademarkInfoApi, trademarkInfo);
};

// 5. 删除品牌
export const reqRemoveTrademarkInfo = (id: number) =>
  request.delete(Api.removeTrademarkInfoApi + `/${id}`);

//6. 更新品牌
export const reqUpdateTrademarkInfo = (trademarkInfo: TrademarkInfoModel) =>
  request.put(Api.updateTrademarkInfoApi, trademarkInfo);
